package com.lifa.controller;

import com.lifa.dao.JicunDao;
import com.lifa.entity.Jicun;
import com.lifa.service.JicunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/jicun")
@Scope("prototype")
public class JicunController {
    @Autowired
    private JicunService jicunService;
    @Autowired
    private JicunDao jicunDao;
    /**
     * 查询
     * @return
     */
    @RequestMapping("/ji1")
    @ResponseBody
    public List<Jicun> list(){
        return jicunService.list();
    }

    @RequestMapping("/queryByNames")
    @ResponseBody
    public Map<String,Object> queryPageByName(String name,int offset,int limit){
        Map<String,Object> map = new HashMap<>() ;
        map.put("rows",jicunDao.queryPage(name,offset,limit)) ;
        map.put("total",jicunDao.getTotalCount(name)) ;
        return  map ;
    }
}
